package com.topisv.tms.web.yhd;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.topisv.tms.entity.User;
import com.topisv.tms.service.account.AccountService;

import net.sf.json.JSONObject;

@Controller
@RequestMapping(value = "/yhdLead")
public class YHDLookController {
	
	private static final Logger log = LoggerFactory.getLogger(YHDLookController.class);

	@Autowired
	private AccountService accountService;
	
	
	
	@RequestMapping(value="ajaxUpdateUser")
	public void ajaxUpdateUser(@RequestParam(value="jobuuid") String jobuuid,HttpServletResponse response){
		JSONObject json=null;
		PrintWriter out=null;
		User user=null;
		try {
			out=response.getWriter();
			json=new JSONObject();
			log.info("开始审核用户:"+jobuuid);
			user=accountService.findUserByJobuuid(jobuuid);

			if(null==user){
				json.put("status", "-1");
				json.put("content", "该用户UUID不存在");
				out.print(json.toString());
				return;
			}
			
			user.setStatus("1");
			accountService.save(user);
			
			json.put("content", "审核成功");
			json.put("status", "1");
			out.print(json.toString());
		} catch (Exception e) {
			json.put("status", "0");
			json.put("content", e.getMessage());
			out.print(json.toString());
		}
	}
	
}
